//package com.colorfruit.framework.rabbitmq.config;
//
//import org.springframework.amqp.core.Binding;
//import org.springframework.amqp.core.BindingBuilder;
//import org.springframework.amqp.core.DirectExchange;
//import org.springframework.amqp.core.Queue;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//@Configuration
//public class RabbitmqConfig {
//
//    public static final String BANK_ROUTING_KEY = "bankRoutingKey";
//
//    public static final String LOAN_ROUTING_KEY = "loanRoutingKey";
//
//    public static final String BANK_QUEUE = "bankQueue";
//
//    public static final String LOAN_QUEUE = "loanQueue";
//
//    public static final String DiRECT_EXCHANGE="directExchange";
//
//
//    //声明交换机, 并设置交换机持久化
//    @Bean
//    public DirectExchange directExchange(){
//        return new DirectExchange(DiRECT_EXCHANGE, true, false);
//    }
//
//    //声明队列, 并设置持久化
//
//    /**
//     * name ：队列名
//     * durable ：是否持久化
//     * exclusive ：仅创建者可以使用的私有队列，断开后自动删除
//     * autoDelete : 当所有消费客户端连接断开后，是否自动删除队列
//     * @return
//     */
//    @Bean
//    public Queue bankQueue() {
//        return new Queue(BANK_QUEUE, true, false, false);
//    }
//
//    @Bean
//    public Queue loanQueue() {
//        return new Queue(LOAN_QUEUE, true);
//    }
//
//    //交换机绑定队列
//    @Bean
//    public Binding bankBinding(DirectExchange directExchange,Queue bankQueue){
//        return BindingBuilder.bind(bankQueue)
//                .to(directExchange)
//                .with(BANK_ROUTING_KEY);
//    }
//
//    @Bean
//    public Binding loanBinding(DirectExchange directExchange,Queue loanQueue){
//        return BindingBuilder.bind(loanQueue)
//                .to(directExchange)
//                .with(LOAN_ROUTING_KEY);
//    }
//}
